package com.imooc.sell.converter;

import com.imooc.sell.dataobject.OrderMaster;
import com.imooc.sell.dto.OrderDTO;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * The type Order master 2 order dto converter.
 *
 * @author YangYishe
 * @date 2021年09月07日 15:08
 */
public class OrderMaster2OrderDTOConverter {
    /**
     * Convert order dto.
     *
     * @param orderMaster the order master
     * @return the order dto
     * @author YangYishe
     * @date 2021年09月07日 15:08
     */
    public static OrderDTO convert(OrderMaster orderMaster){
        OrderDTO orderDTO=new OrderDTO();
        BeanUtils.copyProperties(orderMaster,orderDTO);
        return orderDTO;
    }

    /**
     * Convert list.
     *
     * @param orderMasterList the order master list
     * @return the list
     * @author YangYishe
     * @date 2021年09月07日 15:08
     */
    public static List<OrderDTO> convert(List<OrderMaster> orderMasterList){
        return orderMasterList.stream().map(OrderMaster2OrderDTOConverter::convert).collect(Collectors.toList());
    }
}
